home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / timidsrc.zip / playmidi.h < prev    next >
C/C++ Source or Header  |  1996-05-20  |  3KB  |  117 lines

  1. /*
  2.  
  3.     TiMidity -- Experimental MIDI to WAVE converter
  4.     Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; either version 2 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.    playmidi.h
  21.  
  22.    */
  23.  
  24. typedef struct {
  25.   int32 time;
  26.   uint8 channel, type, a, b;
  27. } MidiEvent;
  28.  
  29. /* Midi events */
  30. #define ME_NONE     0
  31. #define ME_NOTEON    1
  32. #define ME_NOTEOFF    2
  33. #define ME_KEYPRESSURE    3
  34. #define ME_MAINVOLUME    4
  35. #define ME_PAN        5
  36. #define ME_SUSTAIN    6
  37. #define ME_EXPRESSION    7
  38. #define ME_PITCHWHEEL    8
  39. #define ME_PROGRAM    9
  40. #define ME_TEMPO    10
  41. #define ME_PITCH_SENS    11
  42.  
  43. #define ME_ALL_SOUNDS_OFF    12
  44. #define ME_RESET_CONTROLLERS    13
  45. #define ME_ALL_NOTES_OFF    14
  46. #define ME_TONE_BANK    15
  47.  
  48. #define ME_LYRIC    16
  49.  
  50. #define ME_EOT        99
  51.  
  52. typedef struct {
  53.   int
  54.     bank, program, volume, sustain, panning, pitchbend, expression, 
  55.     mono, /* one note only on this channel -- not implemented yet */
  56.     pitchsens;
  57.   /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar
  58.      processor near you */
  59.   float
  60.     pitchfactor; /* precomputed pitch bend factor to save some fdiv's */
  61. } Channel;
  62.  
  63. /* Causes the instrument's default panning to be used. */
  64. #define NO_PANNING -1
  65.  
  66. typedef struct {
  67.   uint8
  68.     status, channel, note, velocity;
  69.   Sample *sample;
  70.   int32
  71.     orig_frequency, frequency,
  72.     sample_offset, sample_increment,
  73.     envelope_volume, envelope_target, envelope_increment,
  74.     tremolo_sweep, tremolo_sweep_position,
  75.     tremolo_phase, tremolo_phase_increment,
  76.     vibrato_sweep, vibrato_sweep_position;
  77.   
  78.   final_volume_t left_mix, right_mix;
  79.  
  80.   float
  81.     left_amp, right_amp, tremolo_volume;
  82.   int32
  83.     vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS];
  84.   int
  85.     vibrato_phase, vibrato_control_ratio, vibrato_control_counter,
  86.     envelope_stage, control_counter, panning, panned;
  87.  
  88. } Voice;
  89.  
  90. /* Voice status options: */
  91. #define VOICE_FREE 0
  92. #define VOICE_ON 1
  93. #define VOICE_SUSTAINED 2
  94. #define VOICE_OFF 3
  95. #define VOICE_DIE 4
  96.  
  97. /* Voice panned options: */
  98. #define PANNED_MYSTERY 0
  99. #define PANNED_LEFT 1
  100. #define PANNED_RIGHT 2
  101. #define PANNED_CENTER 3
  102. /* Anything but PANNED_MYSTERY only uses the left volume */
  103.  
  104. extern Channel channel[16];
  105. extern Voice voice[MAX_VOICES];
  106.  
  107. extern int32 control_ratio, amp_with_poly, amplification;
  108. extern int32 drumchannels;
  109. extern int adjust_panning_immediately;
  110. extern int voices;
  111.  
  112. #define ISDRUMCHANNEL(c) ((drumchannels & (1<<(c))))
  113.  
  114. extern int play_midi(MidiEvent *el, int32 events, int32 samples);
  115. extern int play_midi_file(char *fn);
  116. extern void dumb_pass_playing_list(int number_of_files, char *list_of_files[]);
  117.